package com.gwm.upload.controller;

import com.gwm.upload.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@RestController
public class UploadController {

    @Autowired
    private UploadService uploadService;

    /**
     * 文件上传到本地
     * @param file
     * @return
     */
    @PostMapping("/image")
    public ResponseEntity<String> uploadImage(MultipartFile file){
        return ResponseEntity.ok(uploadService.uploadImage(file) );
    }


    /**
     * 文件上传到阿里云
     * @return
     */
    @GetMapping("/signature")
    public ResponseEntity<Map> signature(){
        return ResponseEntity.ok(uploadService.signature() );
    }

}